<template>
  <ChartBox width="100%" height="100%" :title="this.$window.title.title1">
    <div class="mydata1-box">
      <div class="data-box" id="mydata1" ref="hot_ref"></div>
    </div>
  </ChartBox>
</template>

<script>
/* eslint-disable */
// import { mapState } from 'vuex';
import ChartOption from "../../common/ChartOption";
import ChartBox from "@/views/components/ChartBox.vue";

export default {
  components: {
    ChartBox,
  },
  data() {
    return {
      xAxisData: [], //x轴数据
      seriesincome: [], //y轴数据
      taskOptionData: {},
    };
  },
  watch: {},
  created() {
    this.taskOptionData = this.$window.taskOptionData;
  },
  mounted() {
    this.initCharts();
    window.addEventListener("resize", this.screenAdapter);
    this.screenAdapter();
  },
  destroyed() {
    window.removeEventListener("resize", this.screenAdapter);
  },
  methods: {
    initCharts() {
      if (!this.myChart) {
        // 传入vuex中存储的静态数据
        const option = ChartOption.taskOption(true, taskOptionData);
        this.myChart = this.$echarts.init(document.getElementById("mydata1"));
        this.myChart.setOption(option);
      } else {
        let data = this.parkorder;
        const option = ChartOption.taskOption(false, data);
        this.myChart.setOption(option);
      }
    },
    screenAdapter() {
      this.titleFontSize = (this.$refs.hot_ref.offsetWidth / 100) * 3.6;
      this.titleFontHeight = (this.$refs.hot_ref.offsetHeight / 100) * 3.6;
      // console.log('this.titleFontHeight',this.titleFontHeight)
      const adpterOption = {
        grid: {
          left: this.titleFontSize * 2,
          right: this.titleFontSize * 2 ,
          top: this.titleFontHeight * 7,
          bottom: this.titleFontHeight * 2
        },
        xAxis: [
          {
            axisLabel: {
              fontSize: this.titleFontSize / this.taskOptionData.Xsize,
            },
          },
        ],
        yAxis: [
          {
            axisLabel: {
              fontSize: this.titleFontSize / this.taskOptionData.Ysize,
            },
          },
        ],
        legend: {
          itemWidth: this.titleFontSize,
          itemHeight: this.titleFontSize / 2,
          itemGap: this.titleFontSize / 2,
          textStyle: {
            fontSize: this.titleFontSize / this.taskOptionData.legendSize,
          },
          top: this.titleFontHeight * 4,
          right: this.titleFontSize ,
        },
        series: [
          {
            radius: this.titleFontSize * 4.5,
            center: ["50%", "60%"],
          },
        ],
      };
      this.myChart.setOption(adpterOption);
      this.myChart.resize();
    },
  },
};
</script>

<style scoped lang='scss'>
@import "../../../assets/css/parkview.scss";

.mydata1-box {
  position: relative;
  min-width: $-pv-minWidth;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  #mydata1 {
    position: absolute;
    top: 3%;
    left: 3%;
    width: 90%;
    height: 90%;
  }
}
</style>